from flask import Flask,request,session,redirect
from .view import account
from .view import order
from .view import task
from .view import user




def auth():
    if request.path.startswith("/static"):
        return
    if request.path=='/login':
        # 继续向后执行 不拦截
        return
    user_info=session.get('user_info')
    if  user_info:
        return
    return redirect('/login')

def create_app():
    app=Flask(__name__)
    app.secret_key='1234ddsadasdsds56'
    #  注册蓝图
    app.register_blueprint(account.ac)
    app.register_blueprint(order.od)
    app.register_blueprint(task.task)
    app.register_blueprint(user.us)
    app.before_request(auth)

    return  app





